import os
import yaml

class ConfigLoader:
    def __init__(self):
        # 获取配置文件列表
        config_files = os.listdir("./project_config")
        del_list = []
        for cf in config_files:
            if not cf.endswith(".yaml"):
                del_list.append(cf)
        for dl in del_list:
            config_files.remove(dl)
        config_files.sort()
        print(f"配置文件列表：{config_files}......")

        self.configs = []
        for i, cfg_file in enumerate(config_files):
            with open("./project_config/" + cfg_file, "r") as cfg_content:
                self.configs.append(yaml.load(cfg_content, Loader=yaml.SafeLoader))
    
    def get_configs(self):
        return self.configs
